package org.oschina.handler.validator.filter;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.validator.GenericValidator;
import org.oschina.handler.validator.IFilter;
import org.oschina.handler.validator.ValidateBean;
import org.springframework.stereotype.Component;

/**
 * 验证是否是邮箱
 */
@Component
public class EmailFilter implements IFilter {
	
	@Override
	public void execute(ValidateBean validateBean)
	{
		if(StringUtils.isBlank(validateBean.getValue()))
			return;

		if(!GenericValidator.isEmail(validateBean.getValue()))
			validateBean.setValue(null);
	}

}